#include <bits/stdc++.h>
using namespace std;

bool kmp(string s, string p) {
	const int SL = s.length();
	const int PL = p.length();
	
	int next[PL];
	next[0] = -1;
	
	int i = 1, j = 0;
	while(i < PL) {
		if (j == -1 || p[i-1] == p[j]) {
			next[i] = next[i-1] + 1;
			++i, ++j;
		} else {
			j = next[j];
		}
	}
	
	i = 0, j = 0;
	while (i<SL && j<PL) {
		if (j == -1 || s[i] == p[j]) {
			++i, ++j;
		} else {
			j = next[j];
		}
	}
	
	return j == PL;
}

int main() {
	string s, r;
	cin >> s >> r;
	cout << kmp(s, r) << endl;
	return 0;
}
